home *** CD-ROM | disk | FTP | other *** search
- //____________________________________________________________
- // SoundResource.c
- //
- // Copyright © Dan Parks Sydow, 1995
- // From the book:
- // "Graphics and Sound Programming Techniques for the Mac",
- // M&T Books, 1995
-
-
- //____________________________________________________________
-
- #include <Sound.h>
-
-
- //____________________________________________________________
-
- void InitializeToolbox( void );
- OSErr PlaySoundResourceSynch( SndChannelPtr, short );
-
-
- //____________________________________________________________
-
- #define rPoliceSiren 9000
-
-
- //____________________________________________________________
-
- void main( void )
- {
- NumVersion theSndMgrVers;
- short theResID;
- OSErr theError;
-
- InitializeToolbox();
-
- theSndMgrVers = SndSoundManagerVersion();
- if ( theSndMgrVers.majorRev < 3 )
- ExitToShell();
-
- theResID = rPoliceSiren;
- theError = PlaySoundResourceSynch( nil, theResID );
- if ( theError != noErr )
- ExitToShell();
- }
-
-
- //____________________________________________________________
-
- OSErr PlaySoundResourceSynch( SndChannelPtr theChannel, short theResID )
- {
- Handle theHandle;
- OSErr theError;
-
- theHandle = GetResource( 'snd ', theResID );
-
- if ( theHandle == nil )
- {
- return ( resProblem );
- }
- else
- {
- HLock( theHandle );
- theError = SndPlay( theChannel, (SndListHandle)theHandle, false );
- HUnlock( theHandle );
-
- ReleaseResource( theHandle );
-
- return ( theError );
- }
- }
-
-
- //____________________________________________________________
-
- void InitializeToolbox( void )
- {
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( 0L );
- FlushEvents( everyEvent, 0 );
- InitCursor();
- }
-